<script setup>
import { useContactStore } from '@/stores/contact';
import { ref, onMounted } from 'vue';

const contactStore = useContactStore();
const loading = ref(true);

onMounted(() => {
  if (!contactStore.loaded) {
    // 如果数据尚未加载，可以显示加载状态
    loading.value = true;
    // 可以在这里添加轮询逻辑或等待WebSocket响应
  } else {
    loading.value = false;
  }
});
</script>

<template>
  <div v-if="loading">加载中...</div>
  <div v-else>
    <div v-for="contact in contactStore.contacts" :key="contact.id">
      {{ contact.name }} - 最后消息: {{ contact.lastMessage }}
    </div>
  </div>
</template>